#ifndef MEMOMAINWINDOW_H
#define MEMOMAINWINDOW_H

#include <QtGui>
#include <QSystemTrayIcon>

class MemoDBConnection;
class MemoStateEditWidget;
class MemoQueryWidget;
class MemoDetailInfoWidget;
class AlarmDialogV1;

namespace Ui {
    class MemoMainWindow;
}

class MemoMainWindow : public QMainWindow {
    Q_OBJECT
public:
    MemoMainWindow(QWidget *parent = 0);
    ~MemoMainWindow();

protected:
    void changeEvent(QEvent *e);


private:
    Ui::MemoMainWindow *ui;

private slots://uis' slots
    void doActionAbout();
    void doActionAlarm(bool);
private:
    void initUIs();



//------------------------------------------------------------------------------------------------------------------------
//QSystemTrayIcon
//------------------------------------------------------------------------------------------------------------------------
private:
    QSystemTrayIcon* m_pTrayIcon;

    QMenu* m_pTrayIconMenu;

    QAction* m_pMinimizeAction;
    QAction* m_pMaximizeAction;
    QAction* m_pRestoreAction;
    QAction* m_pQuitAction;

    QIcon m_AppIcon;
    QIcon m_AlarmIcon;

    enum AppState{NoAlarm=0, ThereAreAlarms};
    AppState m_AppState;


    void initiateSystemTrayIcon();

protected:
    void closeEvent(QCloseEvent* event);

private slots:
    void iconActivated(QSystemTrayIcon::ActivationReason reason);
    void ThereAreNewAlarms(int);
public slots:
    void showMessage(int _dAlarmCount);
    void messageClicked();

//------------------------------------------------------------------------------------------------------------------------
//DB Related
//------------------------------------------------------------------------------------------------------------------------
private:
    void initDBRelated();
private:
    MemoDBConnection* m_pMemoDBConnection;

//MemoStateEditWidget
private:
//    MemoStateEditWidget* m_pMemoStateEditWidget;

private slots:
    void doActionMemorandumLabelEditor();

//Central Widget
private:
    QWidget* m_pCentralWidget;
    QSplitter* m_pCentralSpliter;
//MemoQueryWidget
    MemoQueryWidget* m_pMemoQueryWidget;

    QWidget* m_pRightWidget;
    MemoDetailInfoWidget* m_pMemoDetailInfoWidget;
    QPushButton* m_pBtnAddNew;
    QPushButton* m_pBtnDelete;
    QPushButton* m_pBtnModify;
    QPushButton* m_pBtnShow;

    QString m_strCurID;

    AlarmDialogV1* m_pAlarmDialogV1;

private slots:
    void IDChanged(QString);
    void doBtnShow();
    void doBtnAddNew();
    void doBtnDelete();
    void doBtnModify();

};

#endif // MEMOMAINWINDOW_H
